Skip to content

Block Library: Add box-sizing border-box rule to blocks with padding support - #86431

Open
Mustafabharmal wants to merge 3 commits into
WordPress:trunkfrom
Mustafabharmal:fix/43465-box-sizing-blocks
Open

Mustafabharmal wants to merge 3 commits into
WordPress:trunkfrom
Mustafabharmal:fix/43465-box-sizing-blocks

Conversation

@Mustafabharmal

Copy link
Copy Markdown
Contributor

What?

Closes #43465

Adds box-sizing: border-box to the blocks that support padding and border but were missing the rule, following the audit in #43465 (comment):

Why?

For padding and border support to work consistently, each block needs its own box-sizing: border-box rule, as the Cover block has. box-sizing isn't inherited, so the rules on .wp-block-columns, .wp-block-accordion and .wp-block-tabs don't cover their child blocks.

Without the rule, padding and border make a block larger than its set size. For example, a padded Heading or Embed overflows the content width in a constrained layout, a 50% Column with padding grows past 50%, and Post Content with a min-height grows taller than the value set.

How?

  • Adds the same rule and comment used by the Cover block to each block's style.scss.
  • Heading uses h1–h6 :where(.wp-block-heading), so the rule keeps element-level specificity and themes can override it easily.
  • Comments Title, Comments Pagination Numbers, Tab Panels and Terms Query had no stylesheet. Each gets a new style.scss, registered via "style" in block.json and imported in src/style.scss, following Comments Pagination Next: Add border and padding support #64310.
  • Footnotes was previously covered only when the List block's stylesheet happened to load; it now has its own rule.

Intentionally unchanged, as noted in the audit:

  • Paragraph and List Item, which have no block class to target.
  • Comment Author Avatar, which is replaced by Avatar (Avatar already has the rule).
  • Home Link, which supports border only.
  • Table, Accordion Heading and Navigation Overlay Close, where the styles are applied to an inner <table> or <button> element.

The only change that may be visible on existing sites is Heading: padded headings in constrained layouts will now fit the content width instead of overflowing it.

Testing Instructions

  1. Use a theme that does not set box-sizing globally, e.g. Twenty Twenty-Five.
  2. Add a Heading with 50px left/right padding and a border. Check that it no longer overflows the content width.
  3. Add a Columns block and set the first column to 50% width with 100px left/right padding. Check that it stays at 50%.
  4. In the Site Editor, select the Post Content block in a template and set a minimum height and vertical padding. Check that its height matches the minimum height set.
  5. Add an Embed block with padding and a minimum width, plus a Math block with padding. Check that neither overflows the content width.
  6. Add padding and a border to an Accordion Item, an Accordion Panel, Tab Panels, a Tab Panel, Comments Title, Comments Pagination Numbers, Read More (inside a Query Loop) and Terms Query. In the browser dev tools, check that each has box-sizing: border-box and stays within its container.
  7. Add a footnote to a paragraph and give the Footnotes block padding. Check that it doesn't overflow.
  8. Check that the editor and the front end match.

Use of AI Tools

Claude Code (Claude Opus 5.5) was used to investigate the issue, draft the fix, and draft this description. I reviewed all changes and verified the behaviour manually.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mustafabharmal <mustafabharmal@git.wordpress.org>
Co-authored-by: digamber89 <digamberpradhan@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block library /packages/block-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dimensions Design Tools Consistency Follow-up: Review box-sizing settings across blocks

1 participant